(function ($) {
    $.fn.oauth = function (options) {
        var settings = {
            oauth:".oauth"
        };
        if (options) {
            $.extend(settings, options);
        }
        var self, type;
        // 根据条件获取数据
        var getLoginUrl = function (type) {
            $.getJSON(m.app + "/oauth/login/" + type, function (data) {
                if (data.status == 1) {
                    window.location.href = data.data.url;
                } else{
                    alert(data.data);
                }
            });
        };

        $(settings.oauth).click(function () {
            self = this;
            type = $(self).data('oauth');
            if (type) {
                getLoginUrl(type);
            } else {
                alert("第三方登陆数据错误！");
            }
        });
    };
}(jQuery));